/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2023-03-24 09:32:35
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2023-03-26 20:49:26
 * @FilePath: \dashbord\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * 同步路由
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: 'Dashboard', icon: 'dashboard' }
      },
      {
        path: 'dashboard/dataResource',
        name: 'DataResource',
        component: () => import('@/views/dashboard/dataResource/index'),
        meta: { title: 'DataResource', icon: 'dashboard' }
      },
      {
        path: 'dashboard/moduleResource',
        name: 'ModuleResource',
        component: () => import('@/views/dashboard/moduleResource/index'),
        meta: { title: 'ModuleResource', icon: 'dashboard' }
      },
      {
        path: 'dashboard/moduleResourceUsageAmount',
        name: 'ModuleResourceUsageAmount',
        component: () => import('@/views/dashboard/moduleResourceUsageAmount/index'),
        meta: { title: 'ModuleResourceUsageAmount', icon: 'dashboard' }
      },
      {
        path: 'dashboard/apply',
        name: 'Apply',
        component: () => import('@/views/dashboard/apply/index'),
        meta: { title: 'Apply', icon: 'dashboard' }
      },
      {
        path: 'dashboard/applyNum',
        name: 'ApplyNum',
        component: () => import('@/views/dashboard/applyNum/index.vue'),
        meta: { title: 'ApplyNum', icon: 'dashboard' }
      },
      {
        path: 'dashboard/applyNumInfo',
        name: 'ApplyNumInfo',
        component: () => import('@/views/dashboard/applyNum/applyNumInfo.vue'),
        meta: { title: 'ApplyNumInfo', icon: 'dashboard' }
      },
    ]
  },
  {
    path: '/netSource',
    component: Layout,
    redirect: '/netSource',
    children: [
      {
        path: 'index',
        name: 'NetSource',
        component: () => import('@/views/netSource/index'),
        meta: { title: '云网资源', icon: 'dashboard' }
      },
      {
        path: 'sourceIndex',
        name: 'SourceIndex',
        component: () => import('@/views/netSource/sourceIndex.vue'),
        meta: { title: '云网资源', icon: 'dashboard' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
